#include "EngineHeader.h"

namespace LSH
{
namespace GUI
{

Point::Point(void):x(0),y(0)
{
}

Point::Point(int pX, int pY)
{
    x = pX;
    y = pY;
}

Point::~Point(void)
{
}

Size::Size(void):x(0), y(0)
{
}

Size::Size(unsigned sX, unsigned sY)
{
    x = sX;
    y = sY;
}

Size::~Size(void)
{
}

Rect::Rect(void)
{
}


Rect::Rect(const Point& position, const Size& size)
{
     _position = position;
     _size = size;
}

Rect::~Rect(void)
{
}

bool Rect::isPointInRect(const Point& point) const 
{
    unsigned int diffX = point.x - _position.x;
    unsigned int diffY = point.y - _position.y;
    if(point.x > _position.x && (diffX) <= _size.x &&
       point.y > _position.y && (diffY) <= _size.y)
    {
        return true;
    }
    return false;
}

Rect Rect::getIntersection(const Rect& rect) const
{
    Rect temp;
    //Point tempPoint = rect.getPosition();
    //if(tempPoint.y > _position.y)
    //{
    //    if(tempPoint.y < _position.y + _size.y)
    //    {
    //        Size tempSize = rect.getSize();
    //        if(tempPoint.x > _position.x)
    //        {
    //            if(tempPoint.x < _position.x + _size.x)
    //            {
    //                temp.setPoint(Point(_position.x, _position.y));
    //            }
    //        }
    //        else
    //        {

    //        }
    //    }
    //}
    //else
    //{
    //}
    return temp;
}

Rect Rect::getContain(const Rect& rect) const
{
    Point minPoint;
    Point tempPoint = rect.getPosition();
    minPoint.x = (tempPoint.x < _position.x) ? tempPoint.x : _position.x;
    minPoint.y = (tempPoint.y < _position.y) ? tempPoint.y : _position.y;
    Size maxSize;
    Size tempSize = rect.getSize();
    maxSize.x = (tempSize.x < _size.x) ? tempSize.x : _size.x;
    maxSize.y = (tempSize.y < _size.y) ? tempSize.y : _size.y;
    return Rect(minPoint, maxSize);
}

} // GUI
} // LSH
